package net.huashitong.ssydt.provider.exam.service;


import net.huashitong.ssydt.exam.entity.SsExamArticleRecord;
import net.huashitong.ssydt.provider.exam.mapper.SsExamArticleRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.10.30
 */
@Service
@Transactional
public class SsExamArticleRecordServiceImpl implements SsExamArticleRecordService {


    private SsExamArticleRecordMapper mapper;

    @Autowired
    public SsExamArticleRecordServiceImpl(SsExamArticleRecordMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SsExamArticleRecord record) {
        return mapper.insert(record);
    }

    @Override
    public int insertSelective(SsExamArticleRecord record) {
        return mapper.insertSelective(record);
    }

    @Override
    public SsExamArticleRecord selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SsExamArticleRecord record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SsExamArticleRecord record) {
        return mapper.updateByPrimaryKey(record);
    }

    @Override
    public SsExamArticleRecord getNotHistoryByUserIdAndArticleId(String userId, Long articleId) {
        SsExamArticleRecord record = new SsExamArticleRecord();
        record.setUserId(userId);
        record.setArticleId(articleId);
        return mapper.getNotHistoryByUserIdAndArticleId(record);
    }

    @Override
    public int countSubmittedByArticleId(Long articleId) {
        return mapper.countSubmittedByArticleId(articleId);
    }

    @Override
    public int countSubmittedByArticleIdWithLessOrEqualsCorrectNumber(Long articleId, Integer correctNumber) {
        SsExamArticleRecord record = new SsExamArticleRecord();
        record.setArticleId(articleId);
        record.setCorrectNumber(correctNumber);
        return mapper.countSubmittedByArticleIdWithLessOrEqualsCorrectNumber(record);
    }


}
